<template>
  <div :class="{ 'full-black': openVisible }">
    <div class="fixed-action-wrp">
      <div class="fixed-icon-button" @click="openModeSelect">
        <div class="bg-img" :class="[openVisible ? 'close' : `open ${mode}` ]"></div>
      </div>
      <div class="select-button-wrp" :class="{ show: openVisible }">
        <div class="select-button" @click="selectMode('wifi')">
          <div class="bg-img wifi"></div>
        </div>
        <div class="select-button" @click="selectMode('earth')">
          <div class="bg-img earth"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "SurfButton",
  data: () => ({
    mode: 'wifi',
    openVisible: false,
  }),
  methods: {
    openModeSelect: function () {
      this.openVisible = !this.openVisible;
    },
    selectMode: function(val){
      this.openModeSelect()
      this.mode=val
    }
  },
};
</script>

<style scoped>
.full-black {
  z-index: 1;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.8);
}
.fixed-action-wrp {
  position: fixed;
  right: 5vw;
  bottom: 23vw;
}
.fixed-icon-button {
  z-index: 19;
  height: 50px;
  width: 50px;
  padding: 10px;
  background-color: #000;
  border-radius: 50%;
  box-sizing: border-box;
  animation: displayImg 2s ease-out;
}
@keyframes displayImg {
  from {
    width: 0;
    height: 0;
  }

  to {
    width: 50px;
  }
}
.bg-img.close {
  background-image: url("../assets/imgs/close.png");
  animation: rotateFront 1s linear;
}
@keyframes rotateFront {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(180deg);
  }
}
.fixed-icon-button .bg-img.open {
  animation: rotateReverse 1s linear;
}
@keyframes rotateReverse {
  from {
    transform: rotate(180deg);
  }

  to {
    transform: rotate(0);
  }
}
.bg-img.wifi {
  background-image: url("../assets/imgs/wifi.png");
}
.bg-img.earth {
  background-image: url("../assets/imgs/earth.png");
}
.select-button-wrp {
  visibility: hidden;
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: ease-in-out 0.5s;
}
.select-button-wrp.show {
  opacity: 1;
  transform: translate(-50%, -100%);
  visibility: visible;
}
.select-button {
  height: 30px;
  width: 30px;
  padding: 5px;
  background-color: #000;
  border-radius: 50%;
  box-sizing: border-box;
  margin: 5px 0;
}
</style>
